﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoofRunner.Actors.ActorComponents;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using RoofRunner.GameComponents;
using RoofRunner.GameComponents.Rendering;

namespace RoofRunner.Actors
{
    public class Actor
    {
        #region Properties
        public Guid ID { get; set; }
        public ActorComponentList Components { get; set; }


        public Vector3 Position { get; set; }
        public Vector3 Forward { get; set; }
        public Vector3 Up { get; set; }

        public Vector3 Scaling { get; set; }
        #endregion // Properties


        #region Constructors
        public Actor()
            : this(Vector3.Zero)
        {
        }

        public Actor(Vector3 position)
            : this(position, new ActorComponentList())
        {
        }

        public Actor(Vector3 position, ActorComponentList components)
        {
            if (components == null) components = new ActorComponentList();
                        
            this.Components = components;
            this.Components.SetOwnerActor(this);
            this.Position = position;
            this.Forward = Vector3.Forward;
            this.Up = Vector3.Up;
            this.Scaling = Vector3.One;
        }
        #endregion // Constructors


        #region Methods
        public void LoadContent(ContentManager content)
        {
            Components.LoadContent(content);
        }



        public void Update(GameTime gameTime) { Components.Update(gameTime); }
        public void PreRender(GameTime gameTime) { Components.PreRender(gameTime); }
        public void Render(GameTime gameTime, RenderWorld renderWorld) { Components.Render(gameTime, renderWorld); }



        #region Components
        public void AddComponent(ActorComponent component)
        {
            component.Parent = this;
            this.Components.Add(component);
        }
        #endregion // Components
        #endregion // Methods
    }
}
